import 'package:sl_doclever/src/utils/sl_utils.dart';
import 'package:core_extension/core_extension.dart';

class SLJavaCode {
  static String property_List(
    String type,
    String name,
    String remark, {
    bool hasSub = false,
  }) {
    type = hasSub ? 'List<$type>' : 'List';
    return '${setRemark(remark)}'
        '        private $type $name;';
  }

  static String property_List_get_set(
    String type,
    String name, {
    bool hasSub = false,
  }) {
    type = hasSub ? 'List<$type>' : 'List';
    return '        public $type get${name.sl_capitalize()}() {\n'
        '            return $name;\n'
        '        }\n\n'
        '        public void set${name.sl_capitalize()}($type $name) {\n'
        '            this.$name = $name;\n'
        '        }';
  }

  static String property_String(String name, String remark) =>
      '${setRemark(remark)}'
      '        private String* $name;';

  static String property_String_get_set(String name) =>
      '        public String get${name.sl_capitalize()}() {\n'
      '            return $name;\n'
      '        }\n\n'
      '        public void set${name.sl_capitalize()}(String $name) {\n'
      '            this.$name = $name;\n'
      '        }';

  static String property_Map(String type, String name, String remark) =>
      '${setRemark(remark)}'
      '        private $type* $name;';

  static String property_Map_get_set(String type, String name) =>
      '        public $type get${name.sl_capitalize()}() {\n'
      '            return $name;\n'
      '        }\n\n'
      '        public void set${name.sl_capitalize()}($type $name) {\n'
      '            this.$name = $name;\n'
      '        }';

  static String setRemark(String remark) => '        /**\n'
      '         * $remark\n'
      '         */\n';
  static String class_begin(String clsName, String remark) => '/**\n'
      ' * $remark\n'
      ' * @date ${SLUtils.dateString}\n'
      ' */\n'
      'public class $clsName {';
  static String class_end() => '}';
}
